package mock.servicesdirectory.premises.dao.daoimpl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import mock.servicesdirectory.common.entities.Premise;
import mock.servicesdirectory.premises.dao.daointerface.PremiseDao;

public class PremiseDaoImpl extends HibernateDaoSupport implements PremiseDao {

	@Override
	public boolean addPremise(Premise premise) {
		// TODO Auto-generated method stub
		getHibernateTemplate().saveOrUpdate(premise);
		return false;
	}

	@Override
	public List<Premise> getPremise() {
		String sql = "from Premise";
		@SuppressWarnings("unchecked")
		List<Premise> premises = getHibernateTemplate().find(sql);
		return premises;
	}

	@Override
	public boolean updatePremise(Premise premise) {
		// TODO Auto-generated method stub
		return false;
	}
	public List<Premise> getPremise(int orgid){
		String sql="from Premise where OrgID = :orgid";
		Session session = this.getSession();
		Query query = session.createQuery(sql);
		query.setParameter("orgid", orgid);
		List<Premise> premise = query.list() ;
		return premise;
	}
	

	

}
